package org.xq.shiro.common;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;
import org.xq.shiro.pojo.User;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import static org.apache.shiro.web.filter.mgt.DefaultFilter.user;

public class JiaMi {
    /**
     * Shiro的加密工具, 对密码加密
     * @param args
     */
    public static void main(String[] args) {
        //加密方式
        String hashAlgorithmName = "MD5";
        //密码
        Object credentials = "123";
        //盐值
        Object salt = ByteSource.Util.bytes("admin");
        //加密次数
        int hashIterations = 222;
        User u=null;
        Map<String,User> userMap=new HashMap<String, User>();
        Iterator<String> it=userMap.keySet().iterator();
        u=userMap.get(it.next());
        Object result = new SimpleHash(
                hashAlgorithmName, credentials, salt, hashIterations);
        System.out.println(result+":"+u.getUsername());
    }

}
